<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>制定产品设计单工序设计单</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
</head>
<body>
<div  style="color: #0e9aef;margin: 20px;">您正在做的业务是：生产管理--产品生产工序设计--制定产品生产工序设计单</div>
<div style="margin-left: 20px">符合条件的产品总数: <span id="total_number_products"></span>例</div>
<div class="container">
    <form class="form-horizontal" style="margin-top: 20px;" id="manufacture_production_search">
        <div class="form-group">
            <label class="control-label col-md-2">请选择产品I级分类</label>
            <div class="col-md-3">
                <select class="form-control" name="search_firstKindId" id="search_firstKindId">
                    <option value="">--请选择--</option>
                </select>
            </div>
            <label class="control-label col-md-2">请选择产品II级分类</label>
            <div class="col-md-3">
                <select class="form-control" name="search_secondKindId" id="search_secondKindId">
                    <option value="">--请选择--</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">请选择产品III级分类</label>
            <div class="col-md-3">
                <select class="form-control" name="search_thirdKindId" id="search_thirdKindId">
                    <option value="">--请选择--</option>
                </select>
            </div>
            <label class="control-label col-md-2">请输入建档时间</label>
            <div class="col-md-2">
                <input type="date" class="form-control" id="search_registerTime1" name="search_registerTime1">
            </div>
            <div class="col-md-2">
                <input type="date" class="form-control" id="search_registerTime2" name="search_registerTime2">
            </div>
            <div class="col-md-1">
                <input type="button" class="btn btn-info" value="查询" id="production_search_btn">
            </div>
        </div>
    </form>
    <table id="manufacture_file_table"></table>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
    $(function (){
        //I级分类
        firstKind()
        //II级分类
        secondKind()
        //III级分类
        thirdKind()

        setTimeout(function (){
            let num=$("#manufacture_file_table").bootstrapTable("getOptions").totalRows
            $("#total_number_products").html(num)
        },500)

        //查询产品档案表未制定工序组成标志
        $("#manufacture_file_table").bootstrapTable({
            method:"post",
            contentType:"application/x-www-form-urlencoded",
            url:"/design/file/queryUnMakeProcessList",
            // 数据行交替样式
            striped: true,
            // 是否是服务器端分页：server表示服务器端，client表示前端分页
            sidePagination: 'server',
            //初始化加载第一页
            pageNumber: 1,
            //是否分页
            pagination: true,
            // 单页记录数，页大小
            pageSize: 5,
            // 分页列表
            pageList: [8, 10, 20],
            //刷新按钮
            // showRefresh:true,
            // 请求参数
            queryParams: function (params) {
                let obj = {
                    // params.limit获取组件中的页大小
                    // params.offset获取请求数据的起始索引
                    pageSize: params.limit,
                    pageNo: (params.offset / params.limit) + 1,

                    // 查询表单的数据
                    search_firstKindId: $("#manufacture_production_search #search_firstKindId").val(),
                    search_secondKindId: $("#manufacture_production_search #search_secondKindId").val(),
                    search_thirdKindId: $("#manufacture_production_search #search_thirdKindId").val(),
                    search_registerTime1: $("#manufacture_production_search #search_registerTime1").val(),
                    search_registerTime2: $("#manufacture_production_search #search_registerTime2").val()
                }
                return obj;
            },
            // 表格列标题
            columns: [{
                title: "产品编号",
                field: "productId",
                formatter: function (value, row, index) {
                    let html = `<a href="javascript:queryById(${row.id});">${value}</a>`
                    return html
                }
            }, {
                title: "产品名称",
                field: "productName"
            }, {
                title: "档次级别",
                field: "productClass",
                formatter: function (value, row, index) {
                    if (row.productClass === "D001-1")
                        return "高档"
                    else if(row.productClass === "D001-2")
                        return "中档"
                    else
                        return "低档"
                }
            }, {
                title: "I级分类",
                field: "firstKindName"
            }, {
                title: "II级分类",
                field: "secondKindName"
            }, {
                title: "III级分类",
                field: "thirdKindName"
            },{
                title:"产品经理",
                field: "responsiblePerson",
            }, {
                title: "制定设计单",
                formatter: function (value, row, index) {
                   let html=`<a href='javascript:formulate(${row.id});'>制定设计单</a>`
                    return html
                }
            }]

        })

        //点击查询按钮
        $("#manufacture_production_search #production_search_btn").click(function () {
            $("#manufacture_file_table").bootstrapTable("refresh")
        })
    })




    function firstKind() {
        $.post("/design/file/select", {"kid": "1"}, function (res) {
            $("#manufacture_production_search #search_firstKindId option:gt(0)").remove()
            for (let i = 0; i < res.length; i++) {
                let obj = res[i]
                let $op = $("<option>" + obj.kindName + "</option>")
                $op.val(obj.kindId)
                $("#search_firstKindId").append($op)
            }
        })
    }

    function secondKind() {
        $.post("/design/file/select", {"kid": "2"}, function (res) {
            $("#manufacture_production_search #search_secondKindId option:gt(0)").remove()
            for (let i = 0; i < res.length; i++) {
                let obj = res[i]
                let $op = $("<option>" + obj.kindName + "</option>")
                $op.val(obj.kindId)
                $("#search_secondKindId").append($op)
            }
        })
    }

    function thirdKind() {
        $.post("/design/file/select", {"kid": "3"}, function (res) {
            $("#manufacture_production_search #search_thirdKindId option:gt(0)").remove()
            for (let i = 0; i < res.length; i++) {
                let obj = res[i]
                let $op = $("<option>" + obj.kindName + "</option>")
                $op.val(obj.kindId)
                $("#search_thirdKindId").append($op)
            }
        })
    }

    //点击产品编号查询该产品档案信息
    function queryById(id){
        localStorage.setItem("id",id)
        window.location="../design/design_product_file_inquiryUI"
    }
    //点击制定设计单跳转
    function formulate(id){
        localStorage.setItem("id",id)
        window.location="manufacture_process_designUI"
    }
</script>
</body>
</html>